home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue32 / kronos / KRONOS.ZIP / Daytype.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-22  |  4.4 KB  |  150 lines

  1. unit Daytype;
  2.  
  3. interface
  4.  
  5. uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  6.   Buttons, ExtCtrls;
  7.  
  8. type
  9.   TDayTypeDlg = class(TForm)
  10.     OKBtn: TButton;
  11.     CancelBtn: TButton;
  12.     Bevel1: TBevel;
  13.     EditName: TEdit;
  14.     EditFirstShow: TEdit;
  15.     EditLastShow: TEdit;
  16.     EditShowFreq: TEdit;
  17.     Label1: TLabel;
  18.     Label2: TLabel;
  19.     Label3: TLabel;
  20.     Label4: TLabel;
  21.     CheckBoxCh: TCheckBox;
  22.     CheckBoxHo: TCheckBox;
  23.     CheckBoxFl: TCheckBox;
  24.     EditMonth: TEdit;
  25.     LabelMonth: TLabel;
  26.     EditMonthday: TEdit;
  27.     RadioGroup1: TRadioGroup;
  28.     LabelMonthday: TLabel;
  29.     ComboBoxRelType: TComboBox;
  30.     procedure OKBtnClick(Sender: TObject);
  31.     procedure RadioGroup1Click(Sender: TObject);
  32.     procedure FormCreate(Sender: TObject);
  33.   private
  34.     { Private declarations }
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39. var
  40.   DayTypeDlg: TDayTypeDlg;
  41.  
  42. implementation
  43. uses Main ,Kronos;
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TDayTypeDlg.OKBtnClick(Sender: TObject);
  48. begin
  49.      with Form1.UserDay do
  50.      begin
  51.           AName := EditName.Text;
  52.           if RadioGroup1.ItemIndex = 0 then
  53.           begin
  54.              ADate :=
  55.              StrToInt(EditMonth.Text)*100+StrToInt(EditMonthday.Text);
  56.              AnOffset := 0;
  57.              ARelDayType := 0;
  58.           end
  59.           else
  60.           begin
  61.              ADate := 0;
  62.              AnOffset := StrToInt(EditMonth.Text);
  63.              AReldayType := ComboBoxReltype.ItemIndex + 1;
  64.           end;
  65.           AFirstShowUp := StrToInt(EditFirstShow.Text);
  66.           ALastShowUp := StrToInt(EditLastShow.Text);
  67.           AShowUpFrequency := StrToInt(EditShowFreq.Text);
  68.           AChurchDay := CheckBoxCh.Checked;
  69.           AHoliday := CheckBoxHo.Checked;
  70.           AFlagDay := CheckBoxFl.Checked;
  71.           AUserCalc := false;
  72.      end;
  73. end;
  74.  
  75. procedure TDayTypeDlg.RadioGroup1Click(Sender: TObject);
  76. begin
  77.      with ComboBoxReltype do
  78.      begin
  79.           if RadioGroup1.ItemIndex = 0 then
  80.           begin
  81.                Visible := false;
  82.                Left := EditMonthDay.Left + EditMonthDay.Width + 10;
  83.                EditMonthDay.Visible := true;
  84.                LabelMonthday.Caption := 'Monthday';
  85.                LabelMonth.Caption := 'Month';
  86.           end
  87.           else
  88.           begin
  89.                if ItemIndex = -1 then
  90.                   ItemIndex := 0;
  91.                Left := EditMonthDay.Left;
  92.                Visible := true;
  93.                EditMonthDay.Visible := false;
  94.                LabelMonthday.Caption := 'Relative to';
  95.                LabelMonth.Caption := 'Offset';
  96.           end;
  97.      end;
  98.  
  99. end;
  100. procedure TDayTypeDlg.FormCreate(Sender: TObject);
  101. var
  102.    I : integer;
  103.    S : string;
  104. begin
  105.      with Form1 do
  106.      begin
  107.           if ListBoxYe.ItemIndex = -1 then
  108.           begin
  109.                EditName.Text := 'New daytype';
  110.                S := IntToStr(Kronos1.Month);
  111.                Self.EditMonth.Text := S;
  112.                S := IntToStr(Kronos1.Monthday);
  113.                Self.EditMonthday.Text := S;
  114.                EditFirstShow.Text := IntToStr(Kronos1.Year);
  115.                EditLastShow.Text := IntToStr(Kronos1.Year);
  116.                EditShowFreq.Text := '1';
  117.           end
  118.           else
  119.           begin
  120.                with Userday do
  121.                begin
  122.                     EditName.Text := AName;
  123.                     EditFirstShow.Text :=
  124.                     IntToStr(AFirstShowUp);
  125.                     EditLastShow.Text :=
  126.                     IntToStr(ALastShowup);
  127.                     EditShowFreq.Text :=
  128.                     IntToStr(AShowupFrequency);
  129.                     if Date = 0 then
  130.                     begin
  131.                          ComboBoxRelType.ItemIndex := AReldayType - 1;
  132.                          Self.EditMonth.Text := IntToStr(AnOffset);
  133.                          RadioGroup1.ItemIndex := 1;
  134.                     end
  135.                     else
  136.                     begin
  137.                          Self.EditMonth.Text := IntToStr(ADate div 100);
  138.                          Self.EditMonthday.Text := IntToStr(ADate mod 100);
  139.                          RadioGroup1.ItemIndex := 0;
  140.                     end;
  141.                     CheckBoxHo.Checked := AHoliday;
  142.                     CheckBoxCh.Checked := AChurchday;
  143.                     CheckBoxFl.Checked := AFlagday;
  144.                end;
  145.           end;
  146.      end;
  147. end;
  148.  
  149. end.
  150.